package com.acme.team03.net.client;

import java.util.Date;

import com.acme.team03.messages.Message;
import com.acme.team03.messages.TextMessage;
import com.acme.team03.net.MessageHandler;
import com.acme.team03.net.server.ConnectionDispatcher;

public class ClientMessageHandler extends MessageHandler {

	public ClientMessageHandler(ConnectionDispatcher connDispatcher) {
		super(connDispatcher);
	}

	@Override
	protected void processMessage(Message msg) {
		if (msg instanceof TextMessage) {
			TextMessage textMsg = (TextMessage) msg;
			if (textMsg.propertyExists("history")) {
				System.out.println("History : \n" + ((TextMessage) msg).getText());
			} else {
				System.out.println(msg.getProperty("Date") + "> " + ((TextMessage) msg).getText());
			}
		}
	}
}